package com.eulog.gwt.euloggwtlibrary.user.client.ui.musicPlayer;

public class DewMiniMusicPlayer implements MusicPlayer {

	protected String playerUrl = "eulog/user/ui/musicPlayer/dewplayer-mini.swf";
	protected String musicUrl;
	private boolean autoStart = true;
	private boolean autoReplay = true;
	private int width = 0;
	private int height = 0;
	
	public void addMusic(String value) {musicUrl = value;} 

	public boolean getAutoReplay() {return autoReplay;}
	public boolean getAutoStart() {return autoStart;}
	public int getHeight() {return height;}
	public int getWidth() {return width;}
	public void setAutoReplay(boolean value) {autoReplay = value;}
	public void setAutoStart(boolean value) {autoStart = value;}
	public void setHeight(int value) {height = value;}
	public void setWidth(int value) {width = value;}
	
	public String getHtml() {
		StringBuffer sb = new StringBuffer();
		sb.append("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' ");
		sb.append("width='"+getWidth()+"' height='"+getHeight()+"' id='dewplayer' align='middle'> ");
		sb.append("<param name='wmode' value='transparent' /><param name='allowScriptAccess' value='sameDomain' /> ");
		sb.append("<param name='movie' value='");
		
		sb.append(playerUrl);
		sb.append("?mp3=");
		sb.append(musicUrl);
		if(getAutoStart()) sb.append("&amp;autostart=1");
		if(getAutoReplay()) sb.append("&amp;autoreplay=1");
		sb.append("' /> ");
		
		sb.append("<param name='quality' value='high' /><param name='bgcolor' value='FFFFFF' /><embed src='");
		sb.append(playerUrl);
		sb.append("?mp3=");
		sb.append(musicUrl);
		if(getAutoStart()) sb.append("&amp;autostart=1");
		if(getAutoReplay()) sb.append("&amp;autoreplay=1");
		
		sb.append("' quality='high' bgcolor='FFFFFF' width='"+getWidth()+"' height='"+getHeight()+"'> ");
		sb.append("<param name='wmode' ");
		sb.append("value='transparent' /> ");
		sb.append("<param name='movie' ");
		sb.append("value='");
		sb.append(playerUrl);
		sb.append("?mp3=");
		sb.append(musicUrl);
		if(getAutoStart()) sb.append("&amp;autostart=1");
		if(getAutoReplay()) sb.append("&amp;autoreplay=1");
		sb.append("' quality='high' bgcolor='FFFFFF' width='"+getWidth()+"' height='"+getHeight()+"' name='dewplayer' wmode='transparent' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>");
		
		return sb.toString();
	}
}
